package util;

import java.util.Random;
public class ArrayGenerator {

    private static Random random = new Random();;
    /**
     * @param min 设定最小阈值
     * @param max 最大阈值
     * @param num 数组元素个数
     * @return
     */

    public void swap(int[] nums, int i, int j) {
        int tmp = nums[i];
        nums[i] = nums[j];
        nums[j] = tmp;
    }
    
    public static int[] getArray(int min, int max, int num) {
        int[] res = new int[num];
        for (int i = 0; i < num; i++) {
            res[i] = random.nextInt(max - min) + min;
        }
        return res;
    }

    public static int[] getArray(int max, int num) {
        return getArray(0, max, num);
    }

    public static int[] getArray(int num) {
        return getArray(0, Integer.MAX_VALUE, num);
    }

    public static String getString(int maxLen) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < maxLen; i++) {
            sb.append((char)(Math.random() * 128));
        }
        return sb.toString();
    }

    public static String getString() {
        return getString((int)(Math.random() * 100));
    }
    
}
